home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
CU Amiga Super CD-ROM 6
/
CU Amiga Magazine's Super CD-ROM 06 (1996)(EMAP Images)(GB)(Track 1 of 4)[!][issue 1997-01].iso
/
imagine
/
extras
/
tools
/
iiutilities
/
stagescale
< prev
next >
Wrap
Text File
|
1995-01-17
|
4KB
|
92 lines
/*\
*
* ARexx script to reduce or enlarge a stage by a set amount to decrease
* rendering times. (Or so I am told:)
*
* Usage: StageScale <stageFileName> <multiplier>
* Using a 0.5 for <multiplier> will reduce the scene and objects
* to half of its original size, and using 2 will double the size.
*
* Notes:
* Each object is given a line of its own in the output. A "." is
* displayed for each timeline bar that is modified.
* If you reduce or enlarge a file too much you will hit Imagine's
* limit and parts of objecs will start to dissapear or vanish
* completely from the scene. Make sure your scene fits in around
* 16,000 imagine units or so, you have to expetiment to find the
* maximum size.
*
* V1.0 Nov-22-94
* IanSmith@moose.erie.net
*
\*/
Numeric Digits 14 /* Need at least 12 to handle 32 bits */
Parse Arg FileName Change .
If FileName="" Then Do
Say "Usage: StageScale <stageFileName> <multiplier>"
Say " More help is in the header of this file."
Exit
End
If Exists(FileName)=0 Then Do
Say "I can't find "FileName"!"
Exit
End
Temp="TestStage."||Date(D)||Time(S) /* Create temp filename */
Address Command 'Delete QUIET' FileName||".Old" /* Erase backup file */
Call Open(Out,Temp,"W") Open(Con,"*","W")
Call WriteCH(Con,"Multiplying '"FileName"' by" Change)
Call Open(In,FileName,"R") ParseStaging(C2D(SubStr(ReadWrite(In,12),5,4)))
Call Close(In) Close(Out) CLose(Con)
Address Command 'Rename' FileName 'To' FileName||".Old"
Address Command 'Rename' Temp 'To' FileName
Say; Exit
ParseStaging: PROCEDURE EXPOSE Change /* Recursive function */
Parse Arg MaxSize
TotalSize=4
Do Until TotalSize>=MaxSize /* Read MaxSize Bytes */
Name=ReadWrite(In,4)
Size=C2D(ReadWrite(In,4))
If Size//2=1 Then Size=Size+1 /* Add pad byte if needed */
If Name="ISTG" | Name="SOBJ" Then Do
TotalSize=TotalSize+ParseStaging(Size)+8 /* Parse into these hunks */
Iterate
End
TotalSize=TotalSize+Size+8 /* Add SIZE and NAME length */
If Name="NAME" Then Do
Call WriteCh(Con,'A'x||ReadWrite(In,Size)" ")
End; Else If Name="POS2" Then Do /* POZ2 = Position */
Call WriteCh(Con,"p")
Buffer=ReadCH(In,Size)
Call WriteCH(Out,Overlay(FToBin(BinToF(SubStr(Buffer,7,4))*Change)||FToBin(BinToF(SubStr(Buffer,11,4))*Change)||FToBin(BinToF(SubStr(Buffer,15,4))*Change),Buffer,7))
End; Else If Name="OSZ2" Then Do /* OSZ2 = Size */
Call WriteCh(Con,"s")
Buffer=ReadCH(In,Size)
Call WriteCH(Out,Overlay(FToBin(BinToF(SubStr(Buffer,7,4))*Change)||FToBin(BinToF(SubStr(Buffer,11,4))*Change)||FToBin(BinToF(SubStr(Buffer,15,4))*Change),Buffer,7))
End; Else Do
Call ReadWrite(In,Size)
End
End
Return TotalSize
ReadWrite: /* This reads staging data, */
Parse Arg FileHandle , Bytes . /* writes it to the new file */
RWBuffer=ReadCH(FileHandle, Bytes) /* and returns the data. */
Call WriteCH(Out,RWBuffer)
Return RWBuffer
BinToF: /* Convert from Imagine FP nums */
Parse Arg ConvertFNum /* to something we can work with. */
Return C2D(ConvertFNum)/65536
FToBin:
Parse Arg ConvertBNum /* Convert back to Imagine FP. */
If ConvertBNum<0 Then /* D2C(2**31) is broken! */
ConvertBNum=2**32+ConvertBNum*65536
Else
ConvertBNum=ConvertBNum*65536
Return Right(D2C(ConvertBNum/65536%1),2,'00'x)||Right(D2C(ConvertBNum//65536%1),2,'00'x)